(()=>{"use strict";const t="_api/tag-manager/api/v1/tags/",e=`/${t}hosts/`,n={EDITOR:"EDITOR",EDITOR_X:"EDITOR_X",ADI:"ADI",APP_BUILDER:"APP_BUILDER",BUSINESS_MANAGER:"BUSINESS_MANAGER",BUSINESS_MANAGER_EDITOR_X:"BUSINESS_MANAGER_EDITOR_X",SITES_LIST:"SITES_LIST",VIEWER:"VIEWER",LOGO_BUILDER:"LOGO_BUILDER",ART_STORE:"ART_STORE",TEMPLATES:"TEMPLATES",FUNNEL:"FUNNEL",DEV_CENTER:"DEV_CENTER",ARENA:"ARENA",LOGIN_PAGE:"LOGIN_PAGE",LOGIN_PAGE_EDITOR_X:"LOGIN_PAGE_EDITOR_X",PREMIUM:"PREMIUM",PREMIUM_TAGS:"PREMIUM_TAGS",PREMIUM_EDITOR_X_TAGS:"PREMIUM_EDITOR_X_TAGS",SUPPORT:"SUPPORT",ACCOUNT_MANAGER:"ACCOUNT_MANAGER",APP_MARKET_STANDALONE:"APP_MARKET_STANDALONE",COMPONENT_STUDIO:"COMPONENT_STUDIO",PREMIUM_DOMAINS_WHOIS:"PREMIUM_DOMAINS_WHOIS",PREMIUM_DOMAINS:"PREMIUM_DOMAINS",RELEASE_NOTES:"RELEASE_NOTES",PREMIUM_MP_CONTAINER:"PREMIUM_MP_CONTAINER",GET_FEEDBACK:"GET_FEEDBACK",MOBILE_WEB_DASHBOARD:"MOBILE_WEB_DASHBOARD",STUDIO_DASHBOARD:"STUDIO_DASHBOARD",CHANNELS_DASHBOARD:"CHANNELS_DASHBOARD",ENTERPRISE_DASHBOARD:"ENTERPRISE_DASHBOARD"},o=!!document.documentMode;function r(t,e,n){let r;o?(r=document.createEvent("CustomEvent"),r.initCustomEvent(t,!0,!0,n)):r=new CustomEvent(t,{detail:n}),e&&e.dispatchEvent&&setTimeout((()=>{e.dispatchEvent(r)}),0)}const E="TagManagerLoaded",a="LoadingTags",s="TagLoaded",c="TagLoadError",i="TagManagerConfigSet",A="Tag Manager: ",u=function(){let t=!1;try{const e=window;t=e&&e.debug||e.location&&(e.location.search||"").toLowerCase().indexOf("debug=")>-1}catch(t){}return t}();function T(t){u&&console&&console.error(`${A} ${t}`)}function _(t){u&&console&&console.log(`${A} ${t}`)}function O(t){let e=t;try{e=JSON.parse(t)}catch(t){T("Parse error in string"),T(t.message)}return e}function R(t){return O(JSON.stringify(t))}let S=[];const d=[],I=[];let f=[],N={};function M(t){"object"!=typeof t||Array.isArray(t)||(N={...N,...t},r(i,window,R(N)))}function g(t){return Object.keys(t).filter((e=>!!t[e]&&-1===f.indexOf(e)))}function D(t){d.push(t)}function l(t){I.push(t)}function P(t,e,n){const o=()=>{try{if("function"==typeof t)return t(e)}catch(t){T(t)}};return!0===n?setTimeout(o,0):o()}function L(t,e,n,o){return()=>{o(n),function(t){S=S.filter((e=>e.name!==t))}(n.name),r(t,window,{tagName:e,embed:R(n)})}}function U(t,e,n,o){const r=o&&o.headers||{},E=o&&o.query||{};r["content-type"]=r["content-type"]||"application/json";const a=new XMLHttpRequest,s=o&&o.postBody?"POST":"GET",c=`${t}${function(t){let e="";"object"==typeof t&&Object.keys(t).forEach((n=>{if(void 0!==t[n]){const o=encodeURIComponent(t[n]);e+=`${encodeURIComponent(n)}=${o}&`}}));return e=e?e.substr(0,e.length-1):"",e?`?${e}`:""}(E)}`;a.open(s,c,!0),a.onreadystatechange=()=>{if(4===a.readyState){const t=a.status;t<200||t>=300?P(n,{status:t,responseText:a.responseText}):P(e,a.responseText)}},Object.keys(r).forEach((t=>{void 0!==r[t]&&a.setRequestHeader(t,r[t])})),a.send(o&&o.postBody||null)}function p(t){S=t,r(a,window,t),t.forEach((t=>{!function(t,e,n,o){const r=document.createElement("SCRIPT");r.src=t,r.onload=()=>{P(e,t)},r.onerror=e=>{P(n,{error:e,sourceUrl:t})},"object"==typeof o&&Object.keys(o).forEach((t=>{r.setAttribute(t,o[t])})),document.head.appendChild(r)}(t.sourceUrl,L(s,t.name,t,D),L(c,t.name,t,l))}))}function y(t){const e=O(t);var n;e.errors&&e.errors.length>0&&T(JSON.stringify(e.errors)),e.config&&((n=e.config.consentPolicy)&&"object"==typeof n&&(f=[...f,...g(n)]),M(e.config)),e.tags?p(e.tags):_("No embeds found to load")}function h(t,o){if(!t||!n.hasOwnProperty(t)){const e=`Hostname: ${t} not listed`;return _(e),new Error(e)}U(`${e}${t}`,(t=>{y(t)}),(()=>{T(`Error loading tags for host ${t}`)}),{query:{categories:o}})}let C=(t,e)=>{if(!n.hasOwnProperty(t)){const e=`${t} is not listed as a valid host`;return T(e),new Error(e)}h(t),M({language:e}),document.addEventListener("consentPolicyChanged",(e=>function(t,e,n){if(n&&n.detail&&n.detail.policy){const e=g(n.detail.policy);e.length&&h(t,e)}}(t,0,e)))};const m={init:function(t,e){const n=C(t,e);return C=()=>new Error("wixTagManager already initialised"),n},getLoadedTags:function(){return R(d)},getLoadingTags:function(){return R(S)},getLoadErrorTags:function(){return R(I)},getConfig:function(){return R(N)},HOST_NAMES:n};r(E,window,m),window.wixTagManager=m})(); //# sourceMappingURL=hostTags.bundle.min.js.map